package com.zy.entity;

import java.util.Scanner;

import com.zy.service.PlaneServiceImpl;

public class Menu {
	Scanner scan = new Scanner(System.in);
	PlaneServiceImpl psil = new PlaneServiceImpl();
	public void mainMenu() throws Exception {
		System.out.println("*************欢迎使用航班信息管理系统***********\n");
		System.out.print("请选择操作(1.列出所有航班 2.按起飞时间查询 3.按目的地查询 4.删除航班 5.更新航班 6.离开系统):");
		int select = scan.nextInt();
		System.out.println();
		switch(select) {
			case 1:
				psil.getAllPlane();
				System.out.println();
				mainMenu();
				break;
			case 2:
				System.out.print("请输入日期(例如：2018-8-6)：");
				String departureDate = scan.next();
				psil.getPlaneByDepartureDte(departureDate);
				System.out.println();
				mainMenu();
				break;
			case 3:
				System.out.print("请输入目的地(例如：贵州安顺)：");
				String destination = scan.next();
				psil.getPlaneByDestination(destination);
				System.out.println();
				mainMenu();
				break;
			case 4:
				System.out.print("请输入需要删除的航班编号:");
				int num1 = scan.nextInt();
				psil.deletePlane(num1);
				System.out.println();
				mainMenu();
				break;
			case 5:
				System.out.print("请输入需要更新的航班编号:");
				int num2 = scan.nextInt();
				psil.updatePlane(num2);
				System.out.println();
				mainMenu();
				break;
			case 6:
				System.out.println("已经成功退出系统，感谢您的使用！");
				System.exit(0);
			default:
				System.out.println("输入非法，请重新输入！");
				mainMenu();
				break;
		}
	}
}
